<template>
	<view>
		<uni-forms :modelValue="user">
			<uni-forms-item label="金额" name="money">
				<uni-easyinput type="text" v-model="user.money" placeholder="请输入金额" />
			</uni-forms-item>
			<button :plain="false" @click="addMoney()">充值</button>
				<button :plain="false" @click="back()">返回</button>
		</uni-forms>
		<view>{{msg}}</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				msg:'',
				user:{
					username:uni.getStorageSync("token"),/* 同步获取用户名 */
					money:0,
				}
			}
		},
		methods: {
			back(){
				uni.navigateBack({
					
				})
			},
			//充钱
			addMoney(){
				uni.request({
					url:'http://localhost:8081/user/addMoney?username='+this.user.username+'&money='+this.user.money,
					success:(res)=>{
						if(res.data.result){
							this.msg="充值成功";
						}else{
							this.msg="充值失败，稍后重试";
						}
					},
				})
			}
			
		}
	}
</script>

<style>

</style>
